home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Can anyone optimize this VERY simple piece of code?
- Date: Thu, 22 Feb 96 01:41:16 GMT
- Organization: none
- Message-ID: <824953276snz@genesis.demon.co.uk>
- References: <19950700wnr@samtech.demon.co.uk> <31276E30.26C0@ix.netcom.com> <824842585snz@genesis.demon.co.uk> <312A863F.49FC@ix.netcom.com>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <312A863F.49FC@ix.netcom.com>
- hcross@ix.netcom.com "Henry Cross" writes:
-
- >Lawrence Kirby wrote:
- >>
- >> In article <31276E30.26C0@ix.netcom.com>
- >> hcross@ix.netcom.com "Henry Cross" writes:
- >>
- >> >> Personally I'd use a VERY simple language. Assembly!
- >> > This is a job for inline assembly, compiler allowing, or an assembler
- >> >if not.
- >> > However if you must persist in C, use pointers every place possible.
- >>
- >> This hasn't been the case in any reasonable compiler for a number of years
- >> now.
- >>
- >> > For example vgamem[count] could be a pointer that incremented++ vice
- >> > an index to an array. (Which is very expensive computationally.)
- >>
- >> The strength reduction required to convert an index to a pointer is one
- >> of the simpler optimistaion that compilers perform. Code that uses indices
- >> often provides more information to the compiler for optimisation purposes so
- >> may even result in better code generated.
- >
- > Your mileage may vary, according to compiler. The only certain solution
- >would be to examine the code generated by the compiler with the
- >appropriate options turned on.
-
- While it may be useful in this case it is a bad idea in general to
- cramp/obfuscate your coding style simply to support prehistoric compilers.
- Clarity is more important in the vast majority of cases.
-
- In this case it is not likely to make much difference. A more radical change
- is needed for a larger improvement in speed e.g. converting the inner
- loop to a memcpy call, or at least taking as much calculation out of
- it as possible (but again a good compiler may do this for you) and try
- to copy words rather than single chars at a time.
-
- The real problems here are dealing with VGA memory and far pointers, and
- being as efficient as possible on the PC archetecture specifically.
- So this thread is best moved to comp.os.msdos.programmer.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-